package com.cbtx.tablet.ui

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ItemDecoration

/**
 * author : joker.peng
 * e-mail : joker@fiture.com
 * date   : 2021/7/5 1:04 PM
 * desc   :
 */
class SpaceItemDecoration(var space: Int) : ItemDecoration() {
    override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
        super.getItemOffsets(outRect, view, parent, state)
        val lp = view.layoutParams as GridLayoutManager.LayoutParams
        lp.topMargin = space / 2
        lp.leftMargin = space / 2
        lp.rightMargin = space / 2
        lp.bottomMargin = space / 2
    }
}